package com.szgr.baoyin.activity;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.search.geocode.ReverseGeoCodeOption;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.szgr.baoyin.MyApplication;
import com.szgr.baoyin.R;
import com.szgr.baoyin.model.Address;
import com.szgr.baoyin.model.DetailConfig;
import com.szgr.baoyin.model.MyProtectItem;
import com.szgr.baoyin.model.ProtectAddress;
import com.szgr.baoyin.model.ProtectState;
import com.szgr.baoyin.model.ServerInfo;
import com.szgr.baoyin.myview.WheelView;
import com.szgr.baoyin.utils.Constant;
import com.szgr.baoyin.utils.DateUtils;
import com.szgr.baoyin.utils.DialogUtils;
import com.szgr.baoyin.utils.MyTool;
import com.szgr.baoyin.utils.PopMenuDate;
import com.szgr.baoyin.utils.RLog;
import com.szgr.baoyin.utils.ToastUtils;
import com.szgr.baoyin.utils.ViewFindUtils;
import com.szgr.baoyin.volley.Volley;
import com.szgr.baoyin.volley.VolleyInterface;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 预约  、 急修
 */
public class UrgencyFixActivity extends BaseActivity implements PopMenuDate.IPopupWindowsConfirm, VolleyInterface {

    private Intent mIntent;
    private Dialog dialog;
    private TextView tv_00;
    private TextView tv_01;
    private TextView tv_02;
    private TextView tv_03;
    private TextView tv_04;
    private TextView tv_05;
    private TextView tv_06;
    private TextView tv_07;
    private TextView tv_08;
    private TextView tv_09;
    private TextView tv_10;
    private TextView tv_11;
    private TextView tv_12;
    private TextView tv_13;
    private TextView tv_14;
    private TextView tv_15;
    private TextView tv_16;
    private TextView tv_17;
    private List<TextView> allTextView;
    private TextView tv_address;
    private TextView tv_user1;
    private TextView tv_user1Phone;
    private TextView tv_user2;
    private TextView tv_user2Phone;
    private String address_id;
    private ArrayList<MyProtectItem> data;
    private TextView tv_time;
    private TextView tv_code;
    private LinearLayout menuView;
    private int index = 1;
    private Dialog menuDialog;
    private WheelView wheelView;
    private String serialNumber;
    private String where;
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case 400:
                    dialog.show();
                    break;
                case 401:
                    if ("urgency".equals(where)) {
                        ToastUtils.showToast("急修失败");
                    } else if ("order".equals(where)) {
                        ToastUtils.showToast("预约失败");
                    } else {
                        ToastUtils.showToast("首次维保／预约失败");
                    }
                    break;
                case 109:
                    DialogUtils.hideLoadingDialog();
                    ToastUtils.showToast("还没有添加任何地址");
                    break;
                case 110:
                    DialogUtils.hideLoadingDialog();
                    ProtectAddress address = addressList.get(0);
                    tv_address.setText(address.getArea_info() + address.getAddress());
                    tv_user1.setText(address.getGsfzr());
                    tv_user1Phone.setText(address.getGsfzr_tel());
                    tv_user2.setText(address.getJsfzr());
                    tv_user2Phone.setText(address.getJsfzr_tel());
                    //传递的地址ID
                    address_id = address.getAddress_id();
                    break;
                case 234:
                    DialogUtils.hideLoadingDialog();
                    break;
                case 235:
                    DialogUtils.hideLoadingDialog();
                    break;
                case 85:
                    ToastUtils.showToast("您的维保预约我们正在处理，请耐心等待，进入‘我的维保’可以及时了解详情");
                    break;
                case 86:
                    ProtectState protectState = states.get(0);
                    Intent detailIntent = new Intent(UrgencyFixActivity.this, ProtectDetailActivity.class);
                    detailIntent.putExtra("maintenance_id", protectState.getMaintenance_id());
                    startActivity(detailIntent);
                    break;
            }
        }
    };
    private List<ProtectState> states;
    private List<ProtectAddress> addressList;
    private EditText et_other;
    private boolean isOncePro;
    private LinearLayout timeLinear;
    private View timeLine;
    private LinearLayout codeLinear;
    private View codeLine;
    private ServerInfo serverInfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_urgency_fix);
        super.onCreate(savedInstanceState);
    }

    @Override
    public void initActionBar() {
        mIntent = getIntent();
        if (mIntent != null && mIntent.hasExtra("where")) {
            where = mIntent.getStringExtra("where");
        }
        if ("urgency".equals(where)) {
            actionBarTitle.setText("急修");
        } else if ("order".equals(where)) {
            actionBarTitle.setText("预约");
        }
    }

    @Override
    public void initView() {
        dialog = DialogUtils.showCustomerDialog(this,
                "您的预约申请已经提交，稍后服务站工作人员会与您联系，请保持手机通话畅通。", "知道了", "查看详情",
                this, this);

        findViewById(R.id.fix_now).setOnClickListener(this);
        initTextView();
        et_other = ViewFindUtils.find(view, R.id.other);

        if (mIntent != null && mIntent.hasExtra("isOncePro")) {
            isOncePro = mIntent.getBooleanExtra("isOncePro", false);
        }

        if (isOncePro) {
//            timeLinear.setVisibility(View.GONE);
//            timeLine.setVisibility(View.GONE);
//            codeLinear.setVisibility(View.GONE);
//            codeLine.setVisibility(View.GONE);
//            serialNumber = "free";
//            tv_time.setText(DateUtils.paseDate(System.currentTimeMillis()));
            getMyProtect();
        }
    }

    private void getMyProtect() {
        DialogUtils.showLoadingDialog(this, "正在加载中...");
        StringRequest sr = new StringRequest(Request.Method.POST, Constant.URL_MY_PROTECT,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String s) {
                        System.out.println("------>" + s);
                        try {
                            JSONObject jsonObject = new JSONObject(s);
                            JSONObject datas = jsonObject.getJSONObject("datas");
                            JSONArray order_maintenance_list = datas.getJSONArray("$order_maintenance_list");
                            Gson gson = new Gson();
                            data = gson.fromJson(order_maintenance_list.toString(), new TypeToken<List<MyProtectItem>>() {
                            }.getType());
                            if (data != null && data.size() == 0) {
                                mHandler.sendEmptyMessage(234);
                            } else {
                                mHandler.sendEmptyMessage(235);
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        }) {
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> map = new HashMap<>();
                map.put("key", MyApplication.getmInstance().getKey());
                return map;
            }
        };
        MyApplication.getmInstance().addToRequestQueue(sr);
    }

    private void initTextView() {

        allTextView = new ArrayList<>();
        tv_00 = (TextView) findViewById(R.id.tv_00);
        tv_00.setOnClickListener(this);
        tv_01 = (TextView) findViewById(R.id.tv_01);
        tv_01.setOnClickListener(this);
        tv_02 = (TextView) findViewById(R.id.tv_02);
        tv_02.setOnClickListener(this);
        tv_03 = (TextView) findViewById(R.id.tv_03);
        tv_03.setOnClickListener(this);
        tv_04 = (TextView) findViewById(R.id.tv_04);
        tv_04.setOnClickListener(this);
        tv_05 = (TextView) findViewById(R.id.tv_05);
        tv_05.setOnClickListener(this);
        tv_06 = (TextView) findViewById(R.id.tv_06);
        tv_06.setOnClickListener(this);
        tv_07 = (TextView) findViewById(R.id.tv_07);
        tv_07.setOnClickListener(this);
        tv_08 = (TextView) findViewById(R.id.tv_08);
        tv_08.setOnClickListener(this);
        tv_09 = (TextView) findViewById(R.id.tv_09);
        tv_09.setOnClickListener(this);
        tv_10 = (TextView) findViewById(R.id.tv_10);
        tv_10.setOnClickListener(this);
        tv_11 = (TextView) findViewById(R.id.tv_11);
        tv_11.setOnClickListener(this);
        tv_12 = (TextView) findViewById(R.id.tv_12);
        tv_12.setOnClickListener(this);
        tv_13 = (TextView) findViewById(R.id.tv_13);
        tv_13.setOnClickListener(this);
        tv_14 = (TextView) findViewById(R.id.tv_14);
        tv_14.setOnClickListener(this);
        tv_15 = (TextView) findViewById(R.id.tv_15);
        tv_15.setOnClickListener(this);
        tv_16 = (TextView) findViewById(R.id.tv_16);
        tv_16.setOnClickListener(this);
        tv_17 = (TextView) findViewById(R.id.tv_17);
        tv_17.setOnClickListener(this);

        allTextView.add(tv_00);
        allTextView.add(tv_01);
        allTextView.add(tv_02);
        allTextView.add(tv_03);
        allTextView.add(tv_04);
        allTextView.add(tv_05);
        allTextView.add(tv_06);
        allTextView.add(tv_07);
        allTextView.add(tv_08);
        allTextView.add(tv_09);
        allTextView.add(tv_10);
        allTextView.add(tv_11);
        allTextView.add(tv_12);
        allTextView.add(tv_13);
        allTextView.add(tv_14);
        allTextView.add(tv_15);
        allTextView.add(tv_16);
        allTextView.add(tv_17);

        tv_code = (TextView) findViewById(R.id.fix_code);
        tv_time = (TextView) findViewById(R.id.fix_time);
        tv_address = (TextView) findViewById(R.id.fix_address);
        tv_user1 = (TextView) findViewById(R.id.fix_user1);
        tv_user1Phone = (TextView) findViewById(R.id.fix_user1_phone);
        tv_user2 = (TextView) findViewById(R.id.fix_user2);
        tv_user2Phone = (TextView) findViewById(R.id.fix_user2_phone);

        tv_code.setOnClickListener(this);
        tv_time.setOnClickListener(this);
        tv_address.setOnClickListener(this);

        if (mIntent.hasExtra("code")) {
            data = (ArrayList<MyProtectItem>) mIntent.getSerializableExtra("code");
        } else {
            data = new ArrayList<>();
        }

        timeLinear = (LinearLayout) findViewById(R.id.time_linearlayout);
        codeLinear = (LinearLayout) findViewById(R.id.code_linear);
        timeLine = findViewById(R.id.time_line);
        codeLine = findViewById(R.id.code_line);
        if ("urgency".equals(where)) {
            timeLinear.setVisibility(View.GONE);
            timeLine.setVisibility(View.GONE);
            tv_02.setVisibility(View.GONE);
        }

//        getProtectList();
        getAddress();
    }

    private void getAddress() {
        DialogUtils.showLoadingDialog(this, "正在获取地址...");
        StringRequest sr = new StringRequest(Request.Method.POST, Constant.URL_PROTECT_ADDRESS,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String s) {
                        System.out.println("---get address--->" + s);
                        try {
                            JSONObject jsonObject = new JSONObject(s);
                            JSONObject datas = jsonObject.getJSONObject("datas");
                            JSONArray address_list = datas.getJSONArray("address_list");
                            Gson gson = new Gson();
                            addressList = gson.fromJson(address_list.toString(), new TypeToken<List<ProtectAddress>>() {
                            }.getType());
                            if (addressList.size() == 0) {
                                mHandler.obtainMessage(109).sendToTarget();
                            } else {
                                mHandler.obtainMessage(110).sendToTarget();
                            }
                        } catch (JSONException e) {
                            mHandler.obtainMessage(109).sendToTarget();
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                mHandler.obtainMessage(109).sendToTarget();
            }
        }) {
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> map = new HashMap<>();
                map.put("key", MyApplication.getmInstance().getKey());
                return map;
            }
        };
        MyApplication.getmInstance().addToRequestQueue(sr);
    }

    private void getProtectList() {
        StringRequest sr = new StringRequest(Request.Method.POST, Constant.URL_PROBLEM,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String s) {
                        System.out.println("----problem--->" + s);
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        }) {
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> map = new HashMap<>();
                map.put("key", MyApplication.getmInstance().getKey());
                return map;
            }
        };
        MyApplication.getmInstance().addToRequestQueue(sr);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (data != null) {
            switch (resultCode) {
                case 209:
                    ProtectAddress address = (ProtectAddress) data.getSerializableExtra("address");
                    tv_address.setText(address.getArea_info() + address.getAddress());
                    tv_user1.setText(address.getGsfzr());
                    tv_user1Phone.setText(address.getGsfzr_tel());
                    tv_user2.setText(address.getJsfzr());
                    tv_user2Phone.setText(address.getJsfzr_tel());
                    //传递的地址ID
                    address_id = address.getAddress_id();
                    break;
            }
        }
    }

    public void initDialog(String title) {
        menuView = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.layout_wheel_view, null);
        final View confirm = menuView.findViewById(R.id.confirm);
        confirm.setOnClickListener(this);
        View cancel = menuView.findViewById(R.id.cancel);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                menuDialog.dismiss();
                index = 1;
            }
        });
        TextView tv_title = (TextView) menuView.findViewById(R.id.title);
        tv_title.setText(title);
        wheelView = (WheelView) menuView.findViewById(R.id.wheel_view);

        wheelView.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
            @Override
            public void onSelected(int selectedIndex, String item) {
                index = selectedIndex;
            }
        });
        wheelView.setOnItemClickListener(new WheelView.OnItemClickListener() {
            @Override
            public void onItemClick() {
                onClick(confirm);
            }
        });
        menuDialog = MyTool.getMenuDialog(this, menuView);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.confirm:
                MyProtectItem myProtectItem = data.get(index - 1);
                serialNumber = myProtectItem.getSerialno();
                tv_code.setText(myProtectItem.getBrand());

                menuDialog.dismiss();
                index = 1;
                break;
            case R.id.action_bar_left:
                finish();
                break;
            case R.id.fix_now:
//                StringBuffer sb = new StringBuffer();
//                for(int i = 0;i < allTextView.size(); i++){
//                    if(allTextView.get(i).isSelected()){
//                        sb.append(allTextView.get(i).getText().toString().trim() + ";");
//                    }
//                }
//                ToastUtils.showToast(sb.toString());
//                dialog.show();
                if (TextUtils.isEmpty(tv_code.getText().toString().trim())) {
                    ToastUtils.showToast("请选择机床代码");
                    return;
                }

                if ("order".equals(where) && TextUtils.isEmpty(tv_time.getText().toString().trim())) {
                    ToastUtils.showToast("请选择预约时间");
                    return;
                }


                if (TextUtils.isEmpty(tv_address.getText().toString().trim())) {
                    ToastUtils.showToast("请选择预约地址");
                    return;
                }

                boolean temp = false;
                for (int i = 0; i < allTextView.size(); i++) {
                    if (allTextView.get(i).isSelected()) {
                        temp = true;
                    }
                }
                if (!temp) {
                    if (TextUtils.isEmpty(et_other.getText().toString().trim())) {
                        ToastUtils.showToast("请填写备注问题");
                        return;
                    }
                }

                if ("order".equals(where)) {
                    fixNow(Constant.URL_YUYUE);
                } else if ("urgency".equals(where)) {
                    fixNow(Constant.URL_URGENCY);
                }
                break;
            case R.id.protect_buy_now:
                dialog.dismiss();
                finish();
                break;
            case R.id.protect_buy_next:
                dialog.dismiss();
                ProtectState protectState = states.get(0);
                Intent detailIntent = new Intent(this, ProtectDetailActivity.class);
                detailIntent.putExtra("maintenance_id", protectState.getMaintenance_id());
                startActivity(detailIntent);
                break;
            case R.id.fix_code:
                initDialog("选择机床代码");
                List<String> codes = new ArrayList<>();
                for (MyProtectItem mpi : data) {
                    codes.add(mpi.getBrand());
                }
                if (codes.size() > 0) {
                    wheelView.setItems(codes);
                    menuDialog.show();
                } else {
                    ToastUtils.showToast("机床代码未获取");
                }
                break;
            case R.id.fix_time:
                PopMenuDate popMenuDate2 = new PopMenuDate(this, true);
                popMenuDate2.setTitle("选择日期");
                popMenuDate2.setMinYear(MyTool.getCurrentYear());
                popMenuDate2.setMaxYear(MyTool.getCurrentYear() + 5);
                // popMenuDate.setDate("2015-02-28");//默认为今天
                popMenuDate2.setTextViewOfShow(tv_time);
                popMenuDate2.setmListener(this);
                popMenuDate2.show(tv_time, 0, 0);
                break;
            case R.id.fix_address:
                Intent addressIntent = new Intent(this, ProtectAddressActivity.class);
                startActivityForResult(addressIntent, 77);
                break;
            case R.id.tv_00:
                if (tv_00.isSelected()) {
                    tv_00.setSelected(false);
                } else {
                    tv_00.setSelected(true);
                }
                break;
            case R.id.tv_01:
                if (tv_01.isSelected()) {
                    tv_01.setSelected(false);
                } else {
                    tv_01.setSelected(true);
                }
                break;
            case R.id.tv_02:
                if (tv_02.isSelected()) {
                    tv_02.setSelected(false);
                } else {
                    tv_02.setSelected(true);
                }
                break;
            case R.id.tv_03:
                if (tv_03.isSelected()) {
                    tv_03.setSelected(false);
                } else {
                    tv_03.setSelected(true);
                }
                break;
            case R.id.tv_04:
                if (tv_04.isSelected()) {
                    tv_04.setSelected(false);
                } else {
                    tv_04.setSelected(true);
                }
                break;
            case R.id.tv_05:
                if (tv_05.isSelected()) {
                    tv_05.setSelected(false);
                } else {
                    tv_05.setSelected(true);
                }
                break;
            case R.id.tv_06:
                if (tv_06.isSelected()) {
                    tv_06.setSelected(false);
                } else {
                    tv_06.setSelected(true);
                }
                break;
            case R.id.tv_07:
                if (tv_07.isSelected()) {
                    tv_07.setSelected(false);
                } else {
                    tv_07.setSelected(true);
                }
                break;
            case R.id.tv_08:
                if (tv_08.isSelected()) {
                    tv_08.setSelected(false);
                } else {
                    tv_08.setSelected(true);
                }
                break;
            case R.id.tv_09:
                if (tv_09.isSelected()) {
                    tv_09.setSelected(false);
                } else {
                    tv_09.setSelected(true);
                }
                break;
            case R.id.tv_10:
                if (tv_10.isSelected()) {
                    tv_10.setSelected(false);
                } else {
                    tv_10.setSelected(true);
                }
                break;
            case R.id.tv_11:
                if (tv_11.isSelected()) {
                    tv_11.setSelected(false);
                } else {
                    tv_11.setSelected(true);
                }
                break;
            case R.id.tv_12:
                if (tv_12.isSelected()) {
                    tv_12.setSelected(false);
                } else {
                    tv_12.setSelected(true);
                }
                break;
            case R.id.tv_13:
                if (tv_13.isSelected()) {
                    tv_13.setSelected(false);
                } else {
                    tv_13.setSelected(true);
                }
                break;
            case R.id.tv_14:
                if (tv_14.isSelected()) {
                    tv_14.setSelected(false);
                } else {
                    tv_14.setSelected(true);
                }
                break;
            case R.id.tv_15:
                if (tv_15.isSelected()) {
                    tv_15.setSelected(false);
                } else {
                    tv_15.setSelected(true);
                }
                break;
            case R.id.tv_16:
                if (tv_16.isSelected()) {
                    tv_16.setSelected(false);
                } else {
                    tv_16.setSelected(true);
                }
                break;
            case R.id.tv_17:
                if (tv_17.isSelected()) {
                    tv_17.setSelected(false);
                } else {
                    tv_17.setSelected(true);
                }
                break;
        }
    }

    private void fixNow(String url) {
        StringRequest sr = new StringRequest(Request.Method.POST, url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String s) {
                        System.out.println("-----fix--->" + s);
                        try {
                            JSONObject jsonObject = new JSONObject(s);
                            JSONObject datas = jsonObject.getJSONObject("datas");
                            JSONArray maintenanceList = datas.getJSONArray("$maintenance_list");
                            Gson gson = new Gson();
                            states = gson.fromJson(maintenanceList.toString(), new TypeToken<List<ProtectState>>() {
                            }.getType());
                            if (states != null && states.size() > 0) {
                                mHandler.obtainMessage(400).sendToTarget();
                            } else {
                                mHandler.obtainMessage(401).sendToTarget();
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        }) {
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> map = new HashMap<>();
                map.put("serialno", serialNumber);
                if ("order".equals(where)) {
                    map.put("appointment_date", tv_time.getText().toString().trim());
                }

                StringBuffer sb = new StringBuffer();
                for (int i = 0; i < allTextView.size(); i++) {
                    if (allTextView.get(i).isSelected()) {
                        sb.append((i + 1) + ",");
                    }
                }
                if (sb.length() > 0) {
                    sb.deleteCharAt(sb.length() - 1);
                    map.put("problem", sb.toString());
                } else {
                    map.put("problem", "");
                }

                map.put("problem_remark", et_other.getText().toString().trim());
                map.put("key", MyApplication.getmInstance().getKey());
                map.put("address_id", address_id);
                System.out.println("---params--->" + map.toString());
                return map;
            }
        };
        MyApplication.getmInstance().addToRequestQueue(sr);
    }

    @Override
    public void notifyDataChanged(String date, int request) {
        if (request == 909) {
            ToastUtils.showToast("预约时间不在8:00～17:00之间");
        }
    }

    @Override
    public void onSuccess(String s, String tag) {
        RLog.s("--rjp-->" + s);
        try {
            JSONObject jsonObject = new JSONObject(s);
            JSONObject datas = jsonObject.getJSONObject("datas");
            JSONObject maintenance_info = datas.getJSONObject("maintenance_info");
            Gson gson = new Gson();
            serverInfo = gson.fromJson(maintenance_info.toString(), ServerInfo.class);
            try {
                JSONObject technicianInfo = new JSONObject(new Gson().toJson(serverInfo.getMaintenance_technician_info()));
                if (technicianInfo.has("member_truename")) {
                    mHandler.obtainMessage(86).sendToTarget();
                } else {
                    mHandler.obtainMessage(85).sendToTarget();
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onFailed(String tag) {

    }
}